/**
 *拿到资质所以又审核人角色的人
 */
var auditorUser = auditorUser || {};
auditorUser.label = 'auditorUser-select-law';
auditorUser.dataUrl = '/zzsc/audit/auditor_user.do';
auditorUser.optStr = ''; // 下拉列表数据
//初始化
auditorUser.init = function (selector, callback) {
    if (!this.optStr) {
        $.ajax({
            type: "POST",
            url: sysInfo.basePath + auditorUser.dataUrl,
            success: function (result) {
                var $dom = $(selector);
                var productStr = "";
                if ($dom.children().length > 1) {
                    productStr += '<option value="">请选择</option>';
                    $dom.empty();
                }
                if (result) {
                    for (var i = 0; i < result.length; i++) {
                        var item = result[i];
                        var opt = '<option  value="' + item.id + '">' + item.realName + '-' + item.loginName + '</option> ';
                        productStr += opt;
                        auditorUser.optStr += opt;
                    }
                }
                $dom.append(productStr);
                if (callback != null && typeof callback == 'function') {
                    callback();
                }
            }
        });
    } else {
        var $dom = $(selector);
        var productStr = "";
        if ($dom.children().length > 1) {
            productStr += '<option>请选择</option>';
            $dom.empty();
        }
        productStr += this.optStr;
        $dom.append(productStr);
        if (callback != null && typeof callback == 'function') {
            callback();
        }
    }
}

$(function () {
    var label = auditorUser.label;
    var $dom = $('select[' + label + ']');
    auditorUser.init($dom, function () {
        $dom.attr(label, 'true');
        $dom.select2({
            placeholder: "请选择",
            width: "100%",
            language: "zh-CN",
            allowClear: true
        });
    });
});